import React, { useState,useEffect  } from 'react';
import { Modal }from 'antd-mobile';
import http from "../../../model/http";

import Btn from "../../../components/btn/Btn";
import UserMsg from "../userMsg/UserMsg";

const alert = Modal.alert;

function Binding() {
  const query = http.useQuery(),
      hosId = query.get('hosId'),
      userId = query.get('userid'),
      crmId = query.get('crmId'),
      outUserId = query.get('outUserId'),
    [data,setData] = useState({});

  useEffect(()=>{
    http.outPost('/customer/customerDetail',{
      hosId:hosId,customerCrmId:crmId
    }).then(e=>{
      setData(e.baseInfo[0])
    })

    // eslint-disable-next-line react-hooks/exhaustive-deps
  },[])

  let submit = async ()=>{
    let data = await http.outPost('/customer/wxworkUserConfirm',{
      hosId,userId, outUserId, customerCrmId:crmId,
    })
    console.log(data)
    alert('顾客信息','已确认')
  }

  return (
    <div>
      <UserMsg msg={data} hosId={hosId}/>

      <p className="g-p10 g-c8 g-f12">
        注：此信息为您在我院的建档信息，属个人隐私，请勿外传，仔细核对信息无误后点击确认。
      </p>
      <Btn type='primary' onClick={submit}>确认</Btn>
    </div>
  )
}

export default Binding;